#ifndef RAY_H_
#define RAY_H_

#include "Vector.h"

class Ray3f {
public:
	Vector3f point;
	Vector3f direction;
	
	Ray3f() {}
	Ray3f(Vector3f point, Vector3f direction) {
		this->point = point;
		this->direction = direction;
	}
	/*
	int IsIntersectSphere(Vector3f center, float radius) {
		// quadratic equation 
		// d*d*t*t + 2d(e-c)t + (e-c)*(e-c) - R*R = 0
	//	float dec = direction.Dot(point  - center);
		float dd = direction.Dot(direction);
		float ec = (point - center).Dot(point - center);
		float rr = radius*radius;
		float delta = dec*dec - dd*(ec - rr);
		if (delta >= 0) return 1;
		return 0;
	}
	void IntersectSphere(Vector3f center, float radius, int& solution, Vector3f & near, Vector3f & far) {
	//	float dec = direction.Dot(point  - center);
		float dd = direction.Dot(direction);
		float ec = (point - center).Dot(point - center);
		float rr = radius*radius;
		float delta = dec*dec - dd*(ec - rr);
		if (delta >= 0) {
			float t1 = (-dec - sqrt(delta)) / dd;
			float t2 = (-dec + sqrt(delta)) / dd;
			
			near = point + direction*t1;
			far = point + direction*t2;
			if (delta) solution = 2;
			else solution = 1;
		} else {
			solution = 0;
		}
	}*/
};

#endif /*RAY_H_*/
